package com.jr.service.impl;

import com.jr.dao.EmailDao;
import com.jr.dao.impl.EmailDaoImpl;
import com.jr.entity.Email;
import com.jr.service.EmailService;

import java.util.List;

public class EmailServiceImpl implements EmailService {
    private EmailDao emailsDao = new EmailDaoImpl();

    /**
     * 新增邮箱
     *
     * @param email 对象
     * @return
     * @throws Exception
     */
    @Override
    public int addEmails(Email email) throws Exception {
        return emailsDao.addEmail(email);
    }

    /**
     * 根据企业id查询邮箱
     *
     * @param enterpriseId
     * @return
     * @throws Exception
     */
    @Override
    public List<Email> selectAllEmail(Integer enterpriseId) throws Exception {
        return emailsDao.listAllEmail(enterpriseId);
    }

    /**
     * 更新email状态
     *
     * @param emailId
     * @return
     * @throws Exception
     */
    @Override
    public int updateEmailExist(Integer emailId) throws Exception {
        return emailsDao.updateEmailExist(emailId);
    }

    /**
     *
     * @param emailName 根据emailName的值进行校验,判断是否存在
     * @return true:已存在   false:不存在
     * @throws Exception
     */
    @Override
    public boolean checkEmailIsExist(String emailName) throws Exception {
        Email email = emailsDao.checkEmailIsExist(emailName);
        return email != null;
    }
    /**
     * 根据id设置邮箱默认值
     * @param emailId
     * @return
     * @throws Exception
     */
    @Override
    public int setEmailDefaultById(Integer emailId) throws Exception {
        return emailsDao.setEmailDefaultById(emailId);
    }

    /**
     * 将所有的默认值改为普通
     * @return
     * @throws Exception
     */
    @Override
    public int setAllEmailDefault() throws Exception {
        return emailsDao.setAllEmailDefault();
    }

}
